package com.csx.governance.traffic.condition.support;

import com.csx.governance.traffic.condition.Component;
import com.csx.governance.traffic.condition.ExpressionComponent;
import com.csx.governance.traffic.condition.constant.CompareOperator;
import com.csx.governance.traffic.condition.constant.ExpressionComponentType;

import java.util.Collections;
import java.util.List;

/**
 * @author cuisongxu
 * @date 2023/2/25 17:39
 */
public class ExcludeExpressionComponent extends ExpressionComponent {

    public ExcludeExpressionComponent(String paramKey, CompareOperator operator, String paramValue) {
        super(paramKey, operator, paramValue);
    }

    @Override
    public String getStatement() {
        return this.paramKey + "?." + this.operator.symbol() + "(" + this.paramValue +") == false";
    }

    public static class Builder extends ExpressionComponent.Builder {

        @Override
        public List<String> supportedConfigIds() {
            return Collections.singletonList(ExpressionComponentType.EXP.name() + "." + CompareOperator.EXCLUDE.name());
        }

        @Override
        protected Component doBuild(String paramKey, CompareOperator operator, String paramValue) {
            return new ExcludeExpressionComponent(paramKey, operator, paramValue);
        }
    }
}
